package com.example.jdshopdeail.fragment;

import android.util.Log;
import android.webkit.WebView;
import android.widget.ImageView;

import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.jdshopdeail.R;
import com.example.jdshopdeail.adapter.BodyDetailAdapter;
import com.example.jdshopdeail.base.App;
import com.example.jdshopdeail.base.BaseFragment;
import com.example.jdshopdeail.util.GlideUtils;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * @author: njb
 * @date: 2020/3/24 0024 10:47
 * @desc: 宝贝详情
 */
public class FMBadyDetail extends BaseFragment {
/*    private static  final String detailUrl = "<img src=“popWaterMark/jfs/t1/74692/17/8363/128581/5d63a4a0E8f8eec19/09a435e2ddd1e0a5.jpg”>" +
            "<img src=“popWaterMark/jfs/t1/44162/27/15286/126690/5d7f3cddE2c0ee0ed/c8cb45d7fa835bb6.jpg”>" +
            "<img src=“popWaterMark/jfs/t1/42846/33/13012/92961/5d63a44dE18f06f10/685615247ad89078.jpg”>" +
            "<img src=“popWaterMark/jfs/t1/46135/18/8793/152363/5d63849cE81d84912/92c0f3a5bccefb88.jpg”>" +
            "<img src=“popWaterMark/jfs/t1/67746/39/10377/221486/5d7f3c75E73e9c0cf/9366230e7a938e4a.jpg”>" +
            "<img src=“popWaterMark/jfs/t1/50707/20/7474/143486/5d512bedE89ee4eb4/c9391a499d86a424.jpg”>" +
            "<img src=“popWaterMark/jfs/t1/39796/15/15245/219044/5d63a5daE3c4868b9/bfc8dde37a368cc3.jpg”>" +
            "<img src=“popWaterMark/jfs/t1/71939/24/6999/109125/5d512d28E54f77f6f/c6f19ed77045e28c.jpg”>" +
            "<img src=“popWaterMark/jfs/t1/43433/35/12999/244457/5d63a415E53547aa0/96fd4b24b2402ece.jpg”>" +
            "<img src=“popWaterMark/jfs/t1/72244/38/7096/72011/5d510211E29e8a412/c24b704f82d15fa8.jpg”>" +
            "<img src=“popWaterMark/jfs/t1/36989/15/15020/100701/5d5105ecE53da2c7f/e64aa7b72a18d239.jpg”>" +
            "<img src=“popWaterMark/jfs/t1/45109/3/6404/232793/5d4132a4E272e1694/08e66aeffba9c8c0.jpg”>" +
            "<img src=“popWaterMark/jfs/t1/64087/22/10554/298859/5d7f3d2bEeb065f91/ad3065469034ce52.jpg”>" +
            "<img src=“popWaterMark/jfs/t1/57205/5/6459/123934/5d4132a4E442981db/f1f52435fd37321a.jpg”>" +
            "<img src=“popWaterMark/jfs/t1/73579/9/10573/109217/5d809ecaE8f711868/900dc5e63e764403.jpg”>" +
            "<img src=“popWaterMark/jfs/t1/65523/18/6037/85318/5d4132a4E9e24ec23/19072d835537b84e.jpg”>" +
            "<img src=“popWaterMark/jfs/t1/81805/33/8314/223355/5d63a5feEe675211a/343cd36803c784d6.jpg”>" +
            "<img src=“popWaterMark/jfs/t1/38653/28/7491/85619/5d512c63E1b1cf20b/e61900781e549b52.jpg”>" +
            "<img src=“popWaterMark/jfs/t1/76756/21/7090/87973/5d512c63Ef0646fe3/32b230921e6cb495.jpg”>";*/
    private static final String imgUrl = "<img src=\"/popWaterMark/jfs/t1/76756/21/7090/87973/5d512c63Ef0646fe3/32b230921e6cb495.jpg\" alt=\"\" />" +
            "<img src=\"popWaterMark/jfs/t1/38653/28/7491/85619/5d512c63E1b1cf20b/e61900781e549b52.jpg\" alt=\"\" />" +
            "<img src=\"popWaterMark/jfs/t1/81805/33/8314/223355/5d63a5feEe675211a/343cd36803c784d6.jpg\" alt=\"\" />" +
            "<img src=\"popWaterMark/jfs/t1/65523/18/6037/85318/5d4132a4E9e24ec23/19072d835537b84e.jpg\" alt=\"\" />" +
            "<img src=\"popWaterMark/jfs/t1/73579/9/10573/109217/5d809ecaE8f711868/900dc5e63e764403.jpg\" alt=\"\" />";

    private String content;

    private BodyDetailAdapter adapter;
    @BindView(R.id.rv_detail)
    RecyclerView rvDetail;


    @Override
    protected void loadData() {

        adapter = new BodyDetailAdapter(null);
        rvDetail.setLayoutManager(new LinearLayoutManager(context));
        rvDetail.setAdapter(adapter);

        setHtml(imgUrl);
    }

    private void setHtml(String detailUrl) {

        new Thread(new Runnable() {
            @Override
            public void run() {
                content = detailUrl.replaceAll("src=\"", "src=\"https://img30.360buyimg.com");
                String[] ht = content.split("\"");
                List<String> list = new ArrayList<>();
                for (String rx : ht) {
                    if (rx.contains("https")) {
                        list.add(rx);
                        Log.d("---url---",rx);
                    }
                }
                adapter.setNewData(list);
            }
        }).start();

    }

    @Override
    protected int getLayoutId() {
        return R.layout.fm_body_detail;
    }

    @Override
    protected void initView() {

    }

    @Override
    protected void addListener() {

    }
}
